Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add support to multiple HTTP response status codes πŸ§‘β€πŸ’» #16

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

luizhlelis
Copy link
Contributor

Summary

Add support to multiple HTTP response status codes πŸ§‘β€πŸ’»

Fixes #8

@luizhlelis
Copy link
Contributor Author

Can any of the maintainers take a look at this? @rafaelpadovezi, @willianantunes, @ricardochaves
Probably, sonar is not prepared to accept community contributions

@luizhlelis
Copy link
Contributor Author

Maybe switching to codecov can be an option. They have an open source plan to encourage this kind of project. I can help you with that setup if you want.

@rafaelpadovezi
Copy link
Member

Thanks for the suggestion @luizhlelis, we will take a look at codecov. Meanwhile, an alteration was made on the CI action to allow your changes build and run tests.

@rafaelpadovezi rafaelpadovezi added the enhancement New feature or request label Jan 13, 2023
@luizhlelis luizhlelis marked this pull request as ready for review January 16, 2023 20:26
@luizhlelis
Copy link
Contributor Author

Thank you @rafaelpadovezi. The PR is now Ready for Review

@@ -25,7 +25,7 @@ public async Task OnActionExecutionAsync_ControllerDoesNotHaveApiControllerAttri

// Act
var response =
await Client.PostAsJsonAsync($"{ControllerWithoutApiAttributeEndpoint}/test-validator", payload);
await HttpClientJsonExtensions.PostAsJsonAsync(Client, $"{ControllerWithoutApiAttributeEndpoint}/test-validator", payload);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: It's realy a minor issue, but I didn't understand why changing the call to PostAsJsonAsync this way. Client.PostAsJsonAsync stopped working? If our custom extension is causing problems I think it's better to remove it since we don't need it anymore.

{
if (item is null)
continue;
var context = new ValidationContext<object>(item);
var result = await validator.ValidateAsync(context);

result.AddToModelState(modelState, string.Empty);
var errorCode = result.Errors?.FirstOrDefault()?.ErrorCode;
Copy link
Member

@rafaelpadovezi rafaelpadovezi Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: The order of the error entries affects the result? If the first validation that fails is a "normal" one and the second one has an .WithErrorCode(ErrorCode.Forbidden); what would be the the error code?

If so, maybe we should add this info to the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to multiple HTTP response status codes
3 participants